#include<cstdio>
using namespace std;
#define ll long long
ll n, l, r;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%lld %lld %lld", &n, &l, &r);
	if ((l / n + 1) * n - 1 <= r)printf("%lld\n", n - 1);
	else printf("%lld\n", r % n);
	return 0;
	fclose(stdin);
	fclose(stdout);
} 
